Subject:Computer SciencePrice: Bought3
Write a C Program - using if else statements, to find the largest number among the given two integer numbers. -
Instructions
· Write comment to make your programs readable.
· Use descriptive variables in your programs (Name of the variables shou ld show their purposes).
· Ensure your code compiles without any errors/warning/deprecations
· Avoid too many & unnecessary usage of white spaces (newline, spaces, tabs, …)
· Try to retain the original code given in the exercise, to avoid any issues in compiling & running your programs
· Always test the program thoroughly, before saving/submitting exercises/project
Hints/Tips
#include<--->
int main()
{
if ( x > y )
{
printf ();
}
else
{
printf ();
}
}
Expected Output
Enter the values for x and y Input: 250 350 Output: Y is large number - 350
Close
Write a C Program to extract a portion of a string from a character string.
-Write comment to make your programs readable. -Use descriptive variables in your programs (Name of the variables shou ld show their purposes). - Ensure your code compiles without any errors/warning/deprecations - Avoid too many & unnecessary usage of white spaces (newline, spaces, tabs, …) - Try to retain the original code given in the exercise, to avoid any issues in compiling & running your programs - Always test the program thoroughly, before saving/submitting exercises/project
void main()
{
l=strlen(str1);
if(m+n-1<l) {="" for(i="n-1," j="0;i<m+n-1;i++,j++)" }="" else="" printf="" ("string="" extraction="" is="" not="" possible");="" ##="" expected="" output="" enter="" the="" string="" manipal="" university="" in="" jaipur="" position="" of="" required="" character:="" 9="" number="" characters="" to="" be="" extracted:="" extracted="" is:="" <="" div="">
</l)>
3.
a) Write a C program, to find both the largest and smallest number in a list of integers using an Array. b) Write a C program, to add two matrices using an Array. c) Write a C program, to multiply two matrices using an Array.
· Write comment to make your programs readable.
· Use descriptive variables in your programs (Name of the variables shou ld show their purposes).
· Ensure your code compiles without any errors/warning/deprecations
· Avoid too many & unnecessary usage of white spaces (newline, spaces, tabs, …)
· Try to retain the original code given in the exercise, to avoid any issues in compiling & running your programs
· Always test the program thoroughly, before saving/submitting exercises/project
void main() { variables; printf("\n =====Matrix Addition=====\n"); for(i=0;i<2;i++) { for(j=0;j<2;j++) { //logic } } printf("\n =====Matrix Multiplication=====\n"); for(i=0;j<2;j++) { for(j=0;j<2;j++) { for(k=0;k<2;k++) { //logic } } } }
a) Enter the max no of array elements: 4 enter the array elements 43 34 45 54 The maximum number in given array is: 54 The minimum number in given array is: 34 b) Enter elements of matrix A:1 2 3 4 Enter elements of matrix B:1 2 3 4 ===== Matrix Addition ===== 2 4 6 8 c) Enter elements of matrix A: 1 2 3 4 Enter elements of matrix B: 1 2 3 4 ===== Matrix Multiplication ===== 6 8 12 32
</math.h>
Close
4.
Problem Statement
Write a C program to find the factorial of a given integer number using both recursive and non-recursive functions.
Instructions
· Write comment to make your programs readable.
· Use descriptive variables in your programs (Name of the variables shou ld show their purposes).
· Ensure your code compiles without any errors/warning/deprecations
· Avoid too many & unnecessary usage of white spaces (newline, spaces, tabs, …)
· Try to retain the original code given in the exercise, to avoid any issues in compiling & running your programs
· Always test the program thoroughly, before saving/submitting exercises/project
Hints/Tips
#include< ----- >
longint fact(int)
void main()
{
variables;
printf(“\n enter an integer no:”);
scanf(“%d”,&n);
// non-recursive
for(i=1;i<=n;i++)
{
//logic for factorial calculation
}
printf(“Factorial of %d = %d using non-recursive logic \n”, n, variables);
// recursive
printf(“Factorial of %d = %d using recursive logic \n”, n, fact(n));
}
longint fact(int n)
{
//logic for factorial calculation
}
Expected Output
Enter the number: 4 Factorial of 4 = 24
5.
Problem Statement
Write a C Program – using pointers To Swap the Values of Two Variables.
Instructions
· Write comment to make your programs readable.
· Use descriptive variables in your programs (Name of the variables shou ld show their purposes).
· Ensure your code compiles without any errors/warning/deprecations
· Avoid too many & unnecessary usage of white spaces (newline, spaces, tabs, …)
· Try to retain the original code given in the exercise, to avoid any issues in compiling & running your programs
· Always test the program thoroughly, before saving/submitting exercises/project
Hints/Tips
# include< ----- >
# include < ------- >
main ( )
{
Variables;
printf ( “ Enter values of x and y: \n”);
scanf( “ %d%d”, x,y);
*temp = ;
*x= ;
*y= ;
printf();
}
Expected Output
Enter values of x and y: 10 20 x=20 y=10
6.
Write a C program – using structures for reading the employee details like employee name, date of joining and salary and also to compute Total salary outgo for a month.
-Write comment to make your programs readable. -Use descriptive variables in your programs (Name of the variables shou ld show their purposes). - Ensure your code compiles without any errors/warning/deprecations - Avoid too many & unnecessary usage of white spaces (newline, spaces, tabs, …) - Try to retain the original code given in the exercise, to avoid any issues in compiling & running your programs - Always test the program thoroughly, before saving/submitting exercises/project
struct personal
{
};
main()
{
variables;
printf (“enter number of employees”); scanf (“%d”,&n);
for (i=1; i<=n; i++)
{
}
printf(“enter the month for total salary”);
scanf(“%s”,month)
for(i=1; i<n; i++)="" {="" }="" printf="" (“the="" total="" salary="" for="" giving="" month="%d”," salary);="" ##="" expected="" output="" input="" values="" chandu="" 25="" january="" 2012="" 5500="" kishore="" 20="" 5500.00="" enter="" the="" 11000.00="" <="" div="">
</n;>
Write a Program which behaves as prescribed in the below problem statement - Take input/output as specified - Print the expected output using the expected logic/algorithm/data - Code is structured correctly and according to the problem statement
Instructions
· Ensure your code compiles without any errors/warning/deprecations
· Follow best practices while coding
· Avoid too many & unnecessary usage of white spaces (newline, spaces, tabs, ...), except to make the code readable
· Use appropriate comments at appropriate places in your exercise, to explain the logic, rational, solutions, so that evaluator can know them
· Try to retain the original code given in the exercise, to avoid any issues in compiling & running your programs
· Always test the program thoroughly, before saving/submitting exercises/project
· For any issues with your exercise, contact your coach
Example
Inputs:
variable1 = input1
variable2 = input2
/* Solution Logic according to asked problem statement */
Expected Output = As described in the problem statement
Warnings
· Take care of whitespace/trailing whitespace
· Trim the output and avoid special characters
· Avoid printing unnecessary values other than expected/asked output
Hints/Tips
int i = 0;
int j = 0 ;
for (int k =0; k < i; k++) {
printf("this is my hint logic %d", i);
}
8.
Write a C Program – to use structure within union, display the structure and length of union elements.
· Write comment to make your programs readable.
· Use descriptive variables in your programs (Name of the variables shou ld show their purposes).
· Ensure your code compiles without any errors/warning/deprecations
· Avoid too many & unnecessary usage of white spaces (newline, spaces, tabs, …)
· Try to retain the original code given in the exercise, to avoid any issues in compiling & running your programs
· Always test the program thoroughly, before saving/submitting exercises/project
Struct hai { }; union bye { }; int main(int argc,char *argv[]) { Struct hai myhai; union bye mybye; …. ….. …..
}
myhai: 1 2 This is myhai mybye: 100 4197476 This is mybye </stdio.h>