Given an int variable n that has already been declared and initialized to a posi
ID: 3798533 • Letter: G
Question
Given an int variable n that has already been declared and initialized to a positive value and another int variable j that has already been declared , use for loop to print a single line consisting of n asterisk. Thus if n contains 5 , five asterisks will be printed. Use no variables other than n and j. ( please use C standard) Given an int variable n that has already been declared and initialized to a positive value and another int variable j that has already been declared , use for loop to print a single line consisting of n asterisk. Thus if n contains 5 , five asterisks will be printed. Use no variables other than n and j. ( please use C standard)Explanation / Answer
#include <stdio.h>
int main()
{
int n = 5;
int j;
for(j=1; j<=5; j++){
printf("* ");
}
printf(" ");
return 0;
}
Output:
sh-4.2$ gcc -o main *.c
sh-4.2$ main
* * * * *
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.