Knowee
Questions
Features
Study Tools

main( ){int i, j ;for ( i = 1 ; i <= 2 ; i++ ){for ( j = 1 ; j <= 2 ; j++ ){if ( i == j )continue ;printf ( “n%d %dn”, i, j ) ;}}}1 22 12 11 23 22 3Error

Question

main( ){int i, j ;for ( i = 1 ; i <= 2 ; i++ ){for ( j = 1 ; j <= 2 ; j++ ){if ( i == j )continue ;printf ( “n%d %dn”, i, j ) ;}}}1 22 12 11 23 22 3Error

🧐 Not the exact question you are looking for?Go ask a question

Solution

The code you've posted is written in C language. It's a simple program that uses nested for loops and an if condition to print out certain values of i and j. However, there seems to be a syntax error in your printf statement. The correct syntax for printf in C language is to use double quotes (" "), not the stylized quotes (“ ”).

Here's the corrected code:

#include<stdio.h>

main( ){
    int i, j;
    for ( i = 1 ; i <= 2 ; i++ ){
        for ( j = 1 ; j <= 2 ; j++ ){
            if ( i == j )
                continue ;
            printf ( "%d %d\n", i, j ) ;
        }
    }
}

This program will print the values of i and j when they are not equal. The 'continue' statement skips the rest of the current loop iteration and continues with the next iteration. So, when i is equal to j, the printf statement is skipped.

The output of this program will be:

1 2
2 1

This is because when i and j are both 1, the printf statement is skipped due to the 'continue' statement. The same happens when i and j are both 2. The other combinations (i=1, j=2 and i=2, j=1) are printed out.

This problem has been solved

Similar Questions

#include <stdio.h>#include<stdlib.h>int main(){ int n; scanf("%d",&n); int a[n]; for(int i=0;i<n;i++){ scanf("%d",&a[i]); } int m=n/2;… printf("%d",a[j]); } for(int k=m;k<n;k++){ printf("%d",a[k]); } } }

Note: This question helps in clearing Cognizant conceptual technical interview12345678910111213#include <stdio.h> int main() { for (int num = 1; num <= 5; num++) { if (num % 2 == 0) { continue; } for (int i = 1; i <= num; i++) { printf("%d ", i); } printf("\n"); } return 0; }

12345678910#include <stdio.h> int main() { int i = 1, j = 5, result = 0; while (i <= j && result <= 40) { result += i * (j - i + 1); printf("%d ", result); i++; } return result; }

Point out the error line in the following program.1. #include<stdio.h>2.  int main()3.  {4.      int i;5.      for(i=5;i<1;i--);6.      break;7.      for(i=6;;i--)8.      {9.          if(i=3)10.          {11.              break;12.          }13.      }14.      for(;;)15.      break;16.      if(i -= 3)17.      printf("%d\n", i);18.      return 0;19.  }

What will the following code output?#include <stdio.h>int main() {    for (int i = 0; i < 3; i++) {        for (int j = 0; j < 3; j++) {            if (i == j) break;            printf("%d%d ", i, j);        }    }    return 0;}

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.