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.

WHAT IS WRONG IN THE FOLLOWING PROGRAM

+1 vote
asked Mar 1, 2019 by ANON
#include <stdio.h>
int main()
{   int i,j,n,k=0;
    printf("enter rows");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        for(j=0;j<=i;j++)
        {
        printf("%d",&k);
        k++;
        }
        printf("\n");
    }
 }

8 Answers

0 votes
answered Mar 1, 2019 by root

in first printf address was not mentioned

commented Mar 1, 2019 by avi
in second printf type only variable name after ","
if we write "&" before variable, it returns memory address of that variable
0 votes
answered Mar 1, 2019 by avi

in second printf type only variable name after ","
if we write "&" before variable, it returns memory address of that variable

0 votes
answered Mar 3, 2019 by anonymous
it should not be printf enter rows instead printf enter the number
0 votes
answered Mar 3, 2019 by anonymous

 printf("%d",k);

0 votes
answered Mar 5, 2019 by Gowsia Tadipatri (140 points)

printf("%d",&k);

for this statement we get memory values of k

printf("%d",k);

for this statement we get k values 

0 votes
answered Mar 5, 2019 by anonymous
in printf & is not allowed
0 votes
answered Mar 7, 2019 by anonymous
At printf("%d",&k); is worng.

It should be printf("%d",k);
0 votes
answered Mar 14, 2019 by anonymous
printf("%d",k) the ampersand u have in second printf is excessive
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...