Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
Need optimised code for the below pattern in c language.
0
votes
asked
Aug 27, 2018
by
anonymous
edited
Aug 27, 2018
1 1 1 2
3 2 2 2
3 3 3 4
Please
log in
or register to answer this question.
1 Answer
+1
vote
answered
Aug 27, 2018
by
kanth
(
200
points)
#include <stdio.h>
int main()
{
int r,i;
printf("enter rows r:");
scanf("%d",&r);
for(i=1;i<=r;i++)
{
if(i%2==1)
{
printf("%d%d%d%d\n",i,i,i,i+1);
}
else
{ printf("%d%d%d%d\n",i+1,i,i,i);
}
}
return 0;
}
commented
Aug 27, 2018
by
anonymous
Thanks a lot, Kanth.
Please
log in
or register to add a comment.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...