2
Answers

some questions in C Programming need answers for my mid exam, I really need help.

sami sam

sami sam

12y
1.7k
1
How do we find out in C, if a number is even?

I answer with this: 
if(number %2==) 
________________________________________
I have only less than 48 hours before my exam start I have to know  the answers of these questions due to my teacher foucs on them for my mid semester exam.
wish me luck, :"(

Regards,
__________________________


Assuming an int 
i already exists, write a for loop that prints 10 %'s on one line, one at a time.
I answer with this: 
for (i=0;i<10;i++) {
 Printf("% ");
 }
_______________________________________
The % operator can be applied to two integers, what is the result of 12 % 5?

_______________________________________
#include <stdio.h>
 
int i, j;
char d;
 
int main() {
  d = 'A';
  for (i=0; i<5; i++) {
  printf("%*c", 5-i, d); 
  for (j=1; j<=i; j++) {
  printf("B");
  }
  printf(" ");
   }
}
Why we got answer like that, I know because we looped it but how it 
functionally is working through the program:
I got output like this:
   A          
   AB
  ABB
 ABBB
ABBBB
_________________________
i AM CONFUAED WITH THIS ONE TOO
 
Write a C program that contains a void function print_a.
The function produces this pattern on the screen:
 
  A
 A A
A  A
AAAAA
A  A
A  A
____________________
What does robust mean when applied to software?

_____________________________
 
  The following code, which was written to produce 10 lines of output each containing the word 2up, contains 5 errors. Mark each one of them with a circle, and describe why it is an error.  [10]

void 2up(void); 
 
int i;
 
int main() {
  for (i:=0; i<10; 1++); {
  2up();
  }
}
 
void 2up(void) {
  printf("2up ");
}
______________________________
           Write a C program that contains a global integer variable number and a void functionprint_number.

  The function prints the value stored in number.
  The output is right justified with leading zeros in a field width of 10 followed by a newline.
  e.g. if number has the value 134 then the function print_number produces:

  0000000134
 
  The main function sets number to 134 and then calls the print_number function.     
it does not work:


#include <stdio.h>
int number;
void print_number() 
{
printf("%010d ",number);
}
void main {)
{
number=134;
print_number();
system("pause");
}
___________________




Answers (2)