Friday, January 29, 2016
queue Array in C
#include <stdio.h>
#include <stdlib.h>
#define max 5
void insert(int) ;
void display() ;
int del() ;
int queue[max] ;
int front = -1 ;
int rear = -1 ;
int main() {
int option , num ;
while(1)
{
printf("\n 1 to insert , \n 2 to delete , \n 3 to display , \n 4 to exit ") ;
scanf("%d" , &option) ;
switch(option) {
case 1:
printf("\n Input a number\n ") ;
scanf("%d" , &num) ;
insert(num) ;
break ;
case 2:
num = del() ;
break ;
case 3:
display() ;
break ;
case 4:
exit(1) ;
default: printf("\n fuck") ;
}
}
return 0 ;
}
void insert(int element) {
if (rear == max-1 ) {
printf("\n queue is full") ;
return ;
}
if(front == -1) {
front = 0 ;
}
rear = rear + 1 ;
queue[rear] = element ;
}
int del() {
int element ;
if (front == -1 || front == rear + 1) {
printf("\n queue is empty ") ;
return ;
}
element = queue[front] ;
front = front + 1 ;
printf("%d is deleted " , element) ;
return element ;
}
void display() {
if (front == -1 || front == rear + 1) {
printf("\n queue is empty ") ;
return ;
}
int i ;
for(i=front ; i <=rear ; i++) {
printf("\n %d , " , queue[i]) ;
}
}
#include <stdlib.h>
#define max 5
void insert(int) ;
void display() ;
int del() ;
int queue[max] ;
int front = -1 ;
int rear = -1 ;
int main() {
int option , num ;
while(1)
{
printf("\n 1 to insert , \n 2 to delete , \n 3 to display , \n 4 to exit ") ;
scanf("%d" , &option) ;
switch(option) {
case 1:
printf("\n Input a number\n ") ;
scanf("%d" , &num) ;
insert(num) ;
break ;
case 2:
num = del() ;
break ;
case 3:
display() ;
break ;
case 4:
exit(1) ;
default: printf("\n fuck") ;
}
}
return 0 ;
}
void insert(int element) {
if (rear == max-1 ) {
printf("\n queue is full") ;
return ;
}
if(front == -1) {
front = 0 ;
}
rear = rear + 1 ;
queue[rear] = element ;
}
int del() {
int element ;
if (front == -1 || front == rear + 1) {
printf("\n queue is empty ") ;
return ;
}
element = queue[front] ;
front = front + 1 ;
printf("%d is deleted " , element) ;
return element ;
}
void display() {
if (front == -1 || front == rear + 1) {
printf("\n queue is empty ") ;
return ;
}
int i ;
for(i=front ; i <=rear ; i++) {
printf("\n %d , " , queue[i]) ;
}
}
Tuesday, January 12, 2016
GTK+ [because i have just drpped java swing ]
Wed 11 2016 13 Jan Saurav Gosaii
#include
<gtk/gtk.h>
int
main(int argc , char* argv[]) {
gtk_init(&argc
, &argv) ;
GtkWidget*
w ;
w =
gtk_window_new(GTK_WINDOW_TOPLEVEL) ;
//
using glib not GTK at next line
g_signal_connect(w , "delete-event" ,
G_CALLBACK(gtk_main_quit) , NULL) ;
gtk_widget_show(w)
;
gtk_main()
;
return
0 ;
}
------------------------------------------------------------------------------------------------------------------------------
#include
<gtk/gtk.h>
int
main(int argc , char* argv[]) {
gtk_init(&argc
, &argv) ;
GtkWidget*
w ;
GtkWidget*
l ;
//
create a root window
w=
gtk_window_new(GTK_WINDOW_TOPLEVEL) ;
gtk_window_set_title(GTK_WINDOW(w)
, "My First APP ") ;
gtk_window_set_default_size(GTK_WINDOW(w)
, 500 , 500) ;
// now
create a label
l =
gtk_label_new("Happy GTK") ;
gtk_label_set_text(GTK_LABEL(l),
"WELCOME TO GTK ") ;
//packing
gtk_container_add(GTK_CONTAINER(w)
, l) ;
gtk_widget_show_all(w)
;
gtk_main()
;
return
0 ;
}
---------------------------------------------------------------------------------------------------------------------------------
#include
<gtk/gtk.h>
int
main(int argc , char* argv[]) {
gtk_init(&argc
, &argv) ;
GtkWidget
*w ;
GtkWidget
*l ;
GtkWidget
*lb ;
GtkWidget
*box ;
w =
gtk_window_new(GTK_WINDOW_TOPLEVEL) ;
gtk_window_set_title(GTK_WINDOW(w)
, "Mano ya Na Mano") ;
gtk_window_set_default_size(GTK_WINDOW(w)
, 500 , 500) ;
l =
gtk_label_new("") ;
gtk_label_set_text(GTK_LABEL(l)
, "Babul Supriya \n Nantu Ghatak") ;
lb =
gtk_label_new("") ;
gtk_label_set_text(GTK_LABEL(lb)
, "Fakiri kor bi re tui ") ;
//box
box =
gtk_box_new(0 , 0) ;
gtk_box_pack_start(GTK_BOX(box)
, l , 0, 0, 0 ) ;
gtk_box_pack_start(GTK_BOX(box)
, lb , 0, 0, 0 ) ;
gtk_container_add(GTK_CONTAINER(w)
, box) ;
gtk_widget_show_all(w)
;
gtk_main()
;
return
0 ;
}
----------------------------------------------------------------------------------------------------------------------------------
#include
<gtk/gtk.h>
#include
<stdio.h>
int
main(int argc , char* argv[]) {
g_print("jjj")
;
printf("\n
yah we can use both ") ;
gint x
, y ;
x =23
;
y = 67
;
gint f
= x +y ;
printf("\n
result is %d " , f) ;
return
0 ;
}
Saturday, October 31, 2015
Wednesday, October 28, 2015
Compile GTK+ project
I have just dropped java swing and start using gtk+. I found pkg-config is not set autometically in Arch . pkg-config <enter> returns error message. pkg-config --libs or pkg-config --cflags returns unexpected results. After long tedious web search i found a right solution which works for me. Here is the syntax --
gcc -Wall -Wextra -std=c99 `pkg-config --cflags --libs gtk+-2.0` file.c -o appName <enter>
and my GTK+ code is compilled successfully.
Update ---
try to find dependencies --
pkg-config --libs --cflags gtk+-3.0
compile -- .c
gcc name.c `pkg-config --libs --cflags gtk+-3.0'
compile --- .c++
g++ name.cpp `pkg-config --libs --cflags gtk+-3.0'
Uff !!!!!!
gcc -Wall -Wextra -std=c99 `pkg-config --cflags --libs gtk+-2.0` file.c -o appName <enter>
and my GTK+ code is compilled successfully.
Update ---
try to find dependencies --
pkg-config --libs --cflags gtk+-3.0
compile -- .c
gcc name.c `pkg-config --libs --cflags gtk+-3.0'
compile --- .c++
g++ name.cpp `pkg-config --libs --cflags gtk+-3.0'
Uff !!!!!!
Friday, October 16, 2015
No Sound : pulseaudio Daemon startup failed [FIXED]
To install pulseaudio server and pavucontrol in Arch , type in terminal ,
pacman -S pulseaudio pavucontrol .
Now start pauseaudio --
pulseaudio --start
and if you are prompted "Daemon startup failed" then just execute the command
--
sudo chown -R username:username /home/username
and try to reload pulseaudio server again.
:-) Enjoy
pacman -S pulseaudio pavucontrol .
Now start pauseaudio --
pulseaudio --start
and if you are prompted "Daemon startup failed" then just execute the command
--
sudo chown -R username:username /home/username
and try to reload pulseaudio server again.
:-) Enjoy
Subscribe to:
Posts (Atom)
Manjaro Linux
I am switching to Manjaro Linux ... But i have always a hidden love for Arch. The main reason behind is stability. I need more stable syst...
-
When you are completing a serious task and constantly open and close several applications then you need a faster Desktop Environment. Xfce...
-
About: Anyone can download and examin. This is free educational purpose program written in JDK9 (jdk9.openjdk ). You can help me by bu...
-
To install Fastboot and adb . open terminal and just type pacman -S android-tools and now you are ready to work.



