Showing posts with label Display. Show all posts
Showing posts with label Display. Show all posts

DISPLAY SOURCE CODE AS OUTPUT IN C PROGRAM

How To DISPLAY SOURCE CODE AS OUTPUT IN C PROGRAM.

#include<stdio.h>
int main(){
    FILE *p;
    char ch;
    p=fopen("raja.c","r");
    while((ch=getc(p))!=-1)
         putchar(ch);
    fclose(p);
    return 0;
}

C Program To Display The Number In A Specific Formats

How to write a C Program to display the number in a specific formats in C Programming Language ?


Solution For C Program :

/*C Program To Display The Number In A Specific Formats*/

#include<stdio.h>
void main()
{
int r, s, n, key;
printf("\nEnter the Value of n : ");
scanf("%d", &n);
key = 1;
for(r = 1; r <= n; r++)
{
for(s = 1; s <= r; s++)
printf("%3d", key++);
printf("\n");
}
}

You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable

C Program that Display a IBM Logo

How to write a C program that Display a IBM Logo in C Programming Language ?

This IBM Logo Program -- A C Program that Display a IBM Logo.

Solution:

  1. /*IBM Logo Program -- A program that Display a IBM Logo*/
  2. #include <stdio.h>
  3. #define RED     "\x1b[31m" // Colours for the logo to make it pretty!
  4. #define GREEN   "\x1b[32m"
  5. #define BLUE    "\x1b[34m"
  6. #define RESET   "\x1b[0m"
  7. int main()
  8. {
  9. /* IBM logo created by me, I use block characters */
  10. printf(GREEN"╔════════════════════════════════════════╗\n");
  11. printf(GREEN"║"BLUE" ▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄   ▄▄▄▄▄       ▄▄▄▄▄"GREEN" ║\n");
  12. printf(GREEN"║"BLUE" ▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄     ▄▄▄▄▄▄"GREEN" ║\n");
  13. printf(GREEN"║"BLUE"   ▄▄▄     ▄▄▄   ▄▄▄   ▄▄▄▄▄▄   ▄▄▄▄▄▄"GREEN"  ║\n");
  14. printf(GREEN"║"BLUE"   ▄▄▄     ▄▄▄▄▄▄▄▄    ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄"GREEN"  ║\n");
  15. printf(GREEN"║"BLUE"   ▄▄▄     ▄▄▄▄▄▄▄▄    ▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄"GREEN"  ║\n");
  16. printf(GREEN"║"BLUE"   ▄▄▄     ▄▄▄   ▄▄▄   ▄▄▄  ▄▄▄▄▄  ▄▄▄"GREEN"  ║\n");
  17. printf(GREEN"║"BLUE" ▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄   ▄▄▄   ▄▄▄▄"GREEN" ║\n");
  18. printf(GREEN"║"BLUE" ▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄   ▄▄▄▄    ▄    ▄▄▄▄"GREEN" ║\n");
  19. printf(GREEN"║"GREEN"                                      "GREEN"  ║\n");
  20. printf(GREEN"║"RED"    FreeBSD lenovo ThinkCentre M58p     "GREEN"║\n");
  21. printf(GREEN"║"RED"       BSD UNIX Operating System        "GREEN"║\n");
  22. printf(GREEN"╚════════════════════════════════════════╝"RESET"\n");
  23. }

LED ON OFF For One Sec/Count and Display on the Attached Serial Monitor

Turns on an LED on for one second, then off for one second, repeatedly. Counts and displays the count on the attached serial monitor

  1. /* Sketch uses 13,808 bytes (12%) of program storage space. Maximum is 108,000 bytes.
  2.    Global variables use 2,592 bytes of dynamic memory.
  3.   Turns on an LED on for one second, then off for one second, repeatedly.
  4.   Counts and displays the count on the attached serial monitor
  5.  */
  6. int n = 0;
  7. void setup() {                
  8.   // initialize the digital pin as an output.
  9.   pinMode(33, OUTPUT);
  10.   // Initialize virtual COM over USB on Maple Mini
  11.   Serial.begin(9600);  // BAUD has no effect on USB serial: placeholder for physical UART
  12.   // wait for serial monitor to be connected.
  13.   while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
  14.   {
  15.     digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
  16.     delay(100);         // fast blink
  17.   }
  18.   Serial.println("Blink LED & count Demo");
  19. }
  20. void loop() {
  21.   digitalWrite(33, HIGH);   // set the LED on
  22.   //delay(5);              // wait for a second
  23.   digitalWrite(33, LOW);    // set the LED off
  24.   Serial.print("Loop #: ");
  25.   n++;
  26.   Serial.println(n);
  27.    
  28.   //delay(5);              // wait
  29. }