2. 1.FIND THE PATTERN!
• n = input (“Enter a positive integer”)
• while n > 0
• c = n
• while c > 0
• print n
• c = c – 1
• end
• n = n - 1
• print newline
• end
10. 5.FIND THE OUTPUT!
What will be the output of the program (sample.c) given below if it is
executed from the command line?
cmd> sample monday tuesday wednesday thursday
/* sample.c */
#include<stdio.h>
int main(int argc, char *argv[]) {
while(--argc>0)
printf("%s", *++argv);
return 0;
}
18. 9.FIND THE OUTPUT!
What will be the output of the program (sample.c) given below if it is
executed from the command line?
cmd> sample friday tuesday sunday
/* sample.c */
#include<stdio.h>
int main(int argc, char *argv[]) {
printf("%c", *++argv[2] );
return 0;
}
19. ANS: 9
• OUPUT : u
• SOLUTION: argv[2]= Tuesday
• ++ argv[2] =uesday;
• %c of ++argv[2] = u
20. 10.FIND THE OUTPUT!
• int main() {
• short int i = 0;
• for(i<=5 && i>=-1; ++i; i>0)
• printf("%u,", i);
• return 0;
• }
21. 11.FIND THE OUTPUT!
• int main() {
• int y=128;
• const int x=y;
• printf("%dn", x);
• return 0;
• }