program for following output using for loop?
1 2 3 4 5
2 3 4 5
3 4 5
4 5
5
Answers were Sorted based on User's Feedback
Answer / dhruv sharma rkdf
#include<stdio.h>
#include<conio.h>
void main(){
int i,j;
clrscr();
for(i=1;i<=5;i++){
for(j=i;j<=5;j++){
printf("%d ",j)
}
printf("\n");
}
getch();
}
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / ep
#include <stdio.h>
int main()
{
for ( int i = 1; i <= 5 ; i++ ) {
for ( int j = i; j <= 5 ; j++ ) {
if ( i != j ) printf (" ");
printf( "%d", j );
};
printf("\n");
}
return 0;
}
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / jayaraj.s
#include <stdio.h>
main()
{
int a,b,i=1;
for(a=i;a<=5;a++)
{
for(b=a;b<=5;b++)
{
printf("%d",b);
}
printf("\n");
i++;
}
getch();
}
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / dhruv sharma rkdf
hello Jayaraj.s..........
your program will give the following compilation error:
"getch should have a prototype"
you need to include "conio.h" header file...
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / atul shukla
#include<stdio.h>
void main()
{
int i,j;
for (i=1;i<=5;i++)
{
for(j=i;j<=5;j++)
printf("%d ",j);
printf("\n");
}
}
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / letskools
I think th correct program is this for the above output
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=0;i<=5;i++)
{
for(j=i;j<=5;j++)
{
printf("%d",j);
}
printf("\n");
}
getch();
}
Is This Answer Correct ? | 2 Yes | 3 No |
Answer / rajarshi bhadra
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=5;i>=0;i--)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
getch();
}
Is This Answer Correct ? | 4 Yes | 7 No |
Is printf a keyword?
How can I prevent another program from modifying part of a file that I am modifying?
What is an auto variable in c?
write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.
What is the use of typedef in c?
Write a program which take a integer from user and tell whether the given variable is squar of some number or not. eg: is this number is 1,4,9,16... or not
When should we use pointers in a c program?
which one is not preprocessor directive a)#if b)#elif c)#undef d)#pragma
16 Answers Accenture, Infosys, TCS, Wipro,
Why is c known as a mother language?
Consider the following C program. #include <stdio.h> int main() { int i; for (i=0;i<3;++i) { fork();fork(); } } How many processes are created when running this program (including the initial one)? Explain
n=7623 { temp=n/10; result=temp*10+ result; n=n/10 }
How do you determine the length of a string value that was stored in a variable?