Quiz:Define int variable and output its value - C Language Basics

C examples for Language Basics:printf

Introduction

Write a program that creates an integer variable called toes.

Have the program set toes 10.

Calculate what twice toes is and what toes squared is.

Print all three values, identifying them.

Demo Code

#include <stdio.h>  
int main(void)  
{  /*from   w  ww .  jav  a  2s . c om*/
    int toes;  
      
    toes = 10;  
      
    printf("toes = %d\n", toes);  

    printf("Twice toes = %d\n", 2 * toes);  
  
    printf("toes squared = %d\n", toes * toes);  
  
    return 0;  
}

Result


Related Tutorials