5.
a) Write the C Statements (all necessary statements) that open the file inf.dat for reading, and open the file outf.dat for writing.
b) Write the C program to write
“Introduction to C-Programming”
to the file outf.dat.
c) Write a C program that reads integers from the file scores.dat. After all the integers have been read, the program writes the sum of all the nonnegative integers to the video display. Assume that the file scores.dat contains at least one integer.
a) Write the C Statements (all necessary statements) that open the file inf.dat for reading, and open the file outf.dat for writing.
b) Write the C program to write
“Introduction to C-Programming”
to the file outf.dat.
c) Write a C program that reads integers from the file scores.dat. After all the integers have been read, the program writes the sum of all the nonnegative integers to the video display. Assume that the file scores.dat contains at least one integer.
Monthly Sales | Income |
Greater than or equal to Rs.50,000 | 375 plus 16% of sales |
Less than Rs. 50,000 but Greater than or equal to Rs. 40,000 | 350 plus 14% of sales |
Less than Rs. 40,000 but Greater than or equal to Rs. 30,000 | 325 plus 12% of sales |
Less than Rs. 30,000 but Greater than or equal to Rs. 20,000 | 300 plus 9% of sales |
Less than Rs. 20,000 but Greater than or equal to Rs. 10,000 | 250 plus 5% of sales |
Less than Rs. 10,000 | 200 plus 3% of sales |
b) What is printed after execution of each of the following C-programs?
1.
void main()
{
float reals[5];
*(reals+1) = 245.8;
*reals = *(reals + 1);
printf(“ %f”, reals[0] );
}
2.
void main( )
{
int nums[3];
int *ptr = nums;
nums[0] = 100;
nums[1] = 1000;
nums[2] = 10000;
printf( “%d\n”, ++*ptr );
printf( “%d”, *ptr );
}
3.
void main()
{
int digit = 0;
while (digit <= 9)
printf( “%d\n”, digit++);
}
4.
void main()
{
int a=7, b=6;
fun1(a,b);
printf(“\n a is %d b is %d”, a, b);
}
int fun1(int c,int d)
{
int e;
e = c * d;
d = 7 * c;
printf(:\n c is %d d is %d e is %d”, c, d, e);
return;
}
1.
void main()
{
float reals[5];
*(reals+1) = 245.8;
*reals = *(reals + 1);
printf(“ %f”, reals[0] );
}
2.
void main( )
{
int nums[3];
int *ptr = nums;
nums[0] = 100;
nums[1] = 1000;
nums[2] = 10000;
printf( “%d\n”, ++*ptr );
printf( “%d”, *ptr );
}
3.
void main()
{
int digit = 0;
while (digit <= 9)
printf( “%d\n”, digit++);
}
4.
void main()
{
int a=7, b=6;
fun1(a,b);
printf(“\n a is %d b is %d”, a, b);
}
int fun1(int c,int d)
{
int e;
e = c * d;
d = 7 * c;
printf(:\n c is %d d is %d e is %d”, c, d, e);
return;
}
(7+[2x4])
7.
a) Write a C function word_count() to count the number of words in a given string and then call in Main().
b) Write a C function print_upper() to prints its character argument in uppercase.
c) Write a macro that clears an array to zero.
a) Write a C function word_count() to count the number of words in a given string and then call in Main().
b) Write a C function print_upper() to prints its character argument in uppercase.
c) Write a macro that clears an array to zero.
(7+4+4)
8.
a) What is a Structure? Define a structure that contains the following members:
i) An integer quantity called acct_no
ii) A character called acct_type
iii) A 40-element character array called name
iv) A floating-point quantity called balance
v) A structure variable called last payment, of type date: defined as an integer called month; an integer called day; an integer called year
vi) Include the user_defined data type account within the definition.
vii) Include structure variable customer, which is 100-element array of structures called account.
b) What is Pointer in C? How Pointers and Arrays are related?
a) Write short notes on any three of the following:
b) Switch statement (give proper syntax and examples)
c) What do you mean by Loop? How while-loop and do-loop differs?
d) What is C Preprocessor? Explain any two C preprocessor commands with example.
e) Break and Continue Statements
a) What is a Structure? Define a structure that contains the following members:
i) An integer quantity called acct_no
ii) A character called acct_type
iii) A 40-element character array called name
iv) A floating-point quantity called balance
v) A structure variable called last payment, of type date: defined as an integer called month; an integer called day; an integer called year
vi) Include the user_defined data type account within the definition.
vii) Include structure variable customer, which is 100-element array of structures called account.
b) What is Pointer in C? How Pointers and Arrays are related?
(8+7)
9a) Write short notes on any three of the following:
b) Switch statement (give proper syntax and examples)
c) What do you mean by Loop? How while-loop and do-loop differs?
d) What is C Preprocessor? Explain any two C preprocessor commands with example.
e) Break and Continue Statements
(3x5)
Write a program in C to calculate and print the Electricity bill of a given customer. The customer ID., Name and
ReplyDeleteunit consumed by the user should be taken from the keyboard and display the total amount to pay to the
customer.