To gain a solid understanding of loops in C Programming.
- Write a program to calculate the sum of first n natural numbers.
- Write a program to find factorial of a number
- Write a program to add numbers until user enters zero
In a text file assignment3.txt
, answer the following questions:
- How many times does "Programming in C rocks!" print?
#include<stdio.h>
int main()
{
int x;
for(x=-1; x<=10; x++)
{
if(x < 5)
continue;
else
break;
printf("Programming in C Rocks!");
}
return 0;
}
-
Explain the difference between a while and a do while loop.
-
In a nested loop, where does control flow go if a break statement is used in the inner loop?
Please include your name and a description in a comment at the top of your code files. Please also include your name at the top of your assignment3.txt file.
All files must be submitted via GitHub by 10:00am 7/1.