Showing posts with label Text. Show all posts
Showing posts with label Text. Show all posts
C Program to Convert Text String to Binary
How to write a C Program to Convert Text String to Binary ?
Solution:
C Program To Store Students Record In A Text File
How to write a C Program To Store Students Record In A Text File in C Programming Language ?
Solution For C Program :
/*C Program To Store Students Record In A Text File.*/
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
FILE *fp;
char another='y';
int marks1,marks2,marks3,marks4,marks5,role;
char name[20];
clrscr();
fp=fopen("Students.txt","w");
if(fp==NULL)
{
puts("Cannot open file");
exit(1);
}
fprintf(fp,"Role No.\tNAME\t PHYSICS CHEMISTRY MATHS S.S.T ENGLISH\n");
while(another=='y')
{
printf("\nEnter name :");
scanf("%s",&name);
printf("Enter your Role No.:");
scanf("%d",&role);
printf("Enter marks in Physics:");
scanf("%d",&marks1);
printf("Enter marks in Chemistry:");
scanf("%d",&marks2);
printf("Enter marks in Mathematics:");
scanf("%d",&marks3);
printf("Enter marks in Social Science:");
scanf("%d",&marks4);
printf("Enter marks in English:");
scanf("%d",&marks5);
fprintf(fp,"%d\t%s\t%d\t%d\t%d\t%d\t%d\n",role, name, marks1,marks2,marks3,marks4,marks5);
printf("Add another record (y/n): ");
fflush(stdin);
another=getche();
}
fclose(fp);
}
You may also learn these C Program/Code :
C Program To Swap Two Numbers Without Using Third Variable
C Program To Print Text Into Uppercase
How to write a C Program to print text into uppercase in C Programming Language ?
Program to Print text into Upper casing until interrupted using CTRL + Z, Program to Final Maximum of Numbers Entered until interrupted by CTRL + Z, Program to Count No of Characters until Interrupted by CTRL + Z
Program to Print text into Upper casing until interrupted using CTRL + Z
Solution For C Program :
#include<stdio.h>
void main()
{
char ch;
printf("\nPlease Enter the Data. To Stop Press CTRL+Z.\n\n");
while((scanf("%c", &ch)) > 0)
if(ch >= 'a' && ch <= 'z')
printf("%c", ch - 'a' + 'A');
else
printf("%c", ch);
}
Program to Final Maxuimum of Numbes Entered until interrupted by CTRL + Z
Solution For C Program :
#include<stdio.h>
void main()
{
int n,max=0;
printf("/nEnter the Numbers : \n\n");
while((scanf("%d", &n)) > 0)
{
printf("\nThe Given Number is : %d.\t", n);
if(max < n)
max = n;
printf("The Maximum at Present is : %d\n", max);
}
}
Program to Count No of Characters until Interrupted by CTRL + Z
Solution For C Program:
#include<stdio.h>
void main()
{
int no_chars = 0;
while(getchar() != EOF)
++no_chars;
printf("\nThe Number of Characters Entered are : %d.", no_chars);
}
You may also learn these C Program/Code :
C Program To Swap Two Numbers Without Using Third Variable
C Program Exchange User Entered Text Between 2 Modules
How to write a C Program to Exchange User Entered Text Between 2 Modules Compiles with the free version of CC5X in C Programming Language ?
Solution:/* nRF2401 test code to run on the 24G demo board, V02, This code will exchange user entered text between 2 modules. Compiles with the free version of CC5X. */ #define Clock_8MHz #include "boot.h" #include "xc8.h" #include "stdint.h" #pragma config |= 0x3F10 //Internal Oscillator, No WDT, MCLR Disabled uint8_t data_array[10]; // maximo 10 bites de dados uint8_t rf_address[5]; // maximo 5 bites de endereco // variaveis programaveis definidas no inicio do main() uint8_t tamanhodado; // tamanho em bites uint8_t endereco[5]; // endereco uint8_t tamanhoend; // tamanho endereco em bites; uint8_t canal; // canal usado void boot_up(void); void configure_transmitter(void); void transmit_data(void); void delay_ms(uint16_t); void main() { uint8_t x; boot_up(); // definicoes programaveis tamanhodado=1; endereco[3]=0x00; // address 21482 (transmissor teste) endereco[2]=0x00; endereco[1]=0x0B; endereco[0]=0xC3; tamanhoend=4; canal=15; //2.4(15 = canal) GHz // apenas indicando que foi ligado for (x = 0; x < 3; x++) { LED1 = 1; delay_ms(25); LED1 = 0; LED2 = 1; delay_ms(25); LED2 = 0; } configure_transmitter(); while(1) { LED1=botao; if(botao==0) data_array[0]=0x00; else data_array[0]=0xFF; transmit_data(); LED2=!LED2; delay_ms(25); } } void transmit_data(void) { uint8_t i, j, temp,j1; CE = 1; //Clock in address na ordem do mais significativo para o menos for(j=0; j < tamanhoend ; j++) { j1=tamanhoend-j-1; temp=endereco[j1]; for(i = 0 ; i < 8 ; i++) { DATA1 = temp.7; CLK1 = 1; CLK1 = 0; temp <<= 1; } } //Clock in the data_array na ordem do mais significativo para o menor for(j=0;j<tamanhodado;j++) { j1=tamanhodado-j-1; temp = data_array[j1]; for(i = 0 ; i < 8 ; i++) { DATA1 = temp.7; CLK1 = 1; CLK1 = 0; temp <<= 1; } } CE = 0; //Start transmission delay_ms(1); } // para controlar o canal e o tamanho da informa??o... //2.4G Configuration - Transmitter //This sets up one RF-24G for shockburst transmission void configure_transmitter(void) { uint8_t i, j, temp, temp1; uint8_t config_setup[14]; //Config Mode CE = 0; CS = 1; //Setup configuration array //=================================================================== //Data bits 111-104 data width on channel 1 (excluding CRC and adrs) is 32, mudado para 8 // definicao dos bits de configuracao no manual da NORDIC config_setup[0] = tamanhodado<<3; // bits 111-104 // como esta eh a configuracao do transmissor, os enderecos e o // address width abaixo nao interessam serao postos em zero... jv set 08 //Data bits 103-64 Channel 2 address - we don't care, set it to 200 config_setup[1] = 0; // bits 103-96 config_setup[2] = 0; // bits 95-88 config_setup[3] = 0; // bits 87-80 config_setup[4] = 0; // bits 79-72 config_setup[5] = 200; // bits 71-64 //Data bits 63-24 Channel 1 address - set it to 21482, conforme projeto config_setup[6] = endereco[4]; // bits 63-56 config_setup[7] = endereco[3]; // bits 55-48 config_setup[8] = endereco[2]; // bits 47-40 config_setup[9] = endereco[1]; // bits 39-32 config_setup[10] = endereco[0]; // bits 31-24 //Data bits 23-16 Address width and CRC (11 para enable e 16bits) config_setup[11] = tamanhoend<<5; // bits 23-16 (aqui eh bits e deslocado) config_setup[11] +=3; // bits 23-16 (aqui eh bits e deslocado) //Data bits 15-8 , potencia 0dBm config_setup[12] = 0b.0110.1111; // bits 15-8 //Data bits 7-0 // canal 2461 => 61 nos bits de 1 a 7 = 0111101 config_setup[13] = canal<<1; // bits 7-0 //=================================================================== //Clock in configuration data for(i = 0 ; i < 14 ; i++) { temp = config_setup[i]; for(j = 0 ; j < 8 ; j++) { DATA1 = temp.7; CLK1 = 1; CLK1 = 0; temp <<= 1; } } //Configuration is actived on falling edge of CS (page 10) CE = 0; CS = 0; }
Subscribe to:
Posts (Atom)